/**
 * 
 */
package br.srv.full.virtual.entities.log;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * @author Delfino
 * 
 */
@Entity
@Table(name = "logcontrol")
@DiscriminatorValue(value = "0")
@DiscriminatorColumn(name = "logtype", discriminatorType = DiscriminatorType.INTEGER)
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class LogControl {

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Integer id;

	@Column(nullable = false, name = "timeLog")
	@Temporal(TemporalType.TIMESTAMP)
	private Date time = new Date();

	@Column(nullable = false)
	private String tag;

	@Column(nullable = false)
	private String message;

	public LogControl() {
		tag = LogControl.class.getSimpleName();
		message = tag;
	}

	/**
	 * @param p_string
	 */
	public LogControl(String p_string) {
		tag = getClass().getSimpleName();
		message = p_string;
	}

	/**
	 * @param p_tag
	 * @param p_msg
	 */
	public LogControl(String p_tag, String p_msg) {
		tag = p_tag;
		message = p_msg;
	}

	/**
	 * @return the id
	 */
	public Integer getId() {
		return id;
	}

	/**
	 * @param p_id
	 *            the id to set
	 */
	public void setId(Integer p_id) {
		id = p_id;
	}

	/**
	 * @return the time
	 */
	public java.util.Date getTime() {
		return time;
	}

	/**
	 * @param p_time
	 *            the time to set
	 */
	public void setTime(java.util.Date p_time) {
		time = p_time;
	}

	/**
	 * @return the tag
	 */
	public String getTag() {
		return tag;
	}

	/**
	 * @param p_tag
	 *            the tag to set
	 */
	public void setTag(String p_tag) {
		tag = p_tag;
	}

	/**
	 * @return the message
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * @param p_message
	 *            the message to set
	 */
	public void setMessage(String p_message) {
		message = p_message;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "[" + getTag() + "] " + getTime() + " - " + getMessage();
	}
}
